// 从 vue-router 库中导入创建路由实例和哈希路由模式的函数
import { createRouter, createWebHashHistory } from "vue-router";

// 创建路由实例并配置路由规则
const router = createRouter({
  // 指定路由的历史模式为哈希模式
  history: createWebHashHistory(),
  routes: [
    {
      path: "/",
      name: "Home",
      component: () => import("../views/home/pageIndex.vue")
    },
    {
      path: "/home",
      name: "HomePage",
      component: () => import("../views/home/pageIndex.vue")
    },
    {
      path: "/scroll",
      name: "Scroll",
      component: () => import("../views/scroll/pageScroll.vue")
    },
    {
      path: "/robscroll",
      name: "RobScroll",
      component: () => import("../views/robScroll/pageRobScroll.vue")
    },
    {
      path: "/order",
      name: "Order",
      component: () => import("../views/order/pageOrder.vue")
    },
    {
      path: "/mine",
      name: "Mine",
      component: () => import("../views/mine/pageIndex.vue")
    },
    {
      path: "/account",
      name: "Account",
      component: () => import("../views/mine/account.vue")
    },
    {
      path: "/verification",
      name: "Verification",
      component: () => import("../views/mine/verification.vue")
    },
    {
      path: "/bindphone",
      name: "BindPhone",
      component: () => import("../views/mine/bindPhone.vue")
    },
    {
      path: "/profile",
      name: "Profile",
      component: () => import("../views/mine/profile.vue")
    },
    {
      path: "/changepassword",
      name: "ChangePassword",
      component: () => import("../views/mine/changePassword.vue")
    },
    {
      path: "/customerservice",
      name: "CustomerService",
      component: () => import("../views/mine/customerService.vue")
    },
    {
      path: "/garbage",
      name: "GarbageClassification",
      component: () => import("../views/mine/garbageClassification.vue")
    },
    {
      path: "/garbage/search",
      name: "GarbageSearchResult",
      component: () => import("../views/mine/garbageSearchResult.vue")
    },
    {
      path: "/product/:id",
      name: "ProductDetail",
      component: () => import("../views/product/productDetail.vue")
    },
    {
      path: "/add-address",
      name: "AddAddress",
      component: () => import("../views/address/AddAddress.vue")
    },
    {
      path: "/select-location",
      name: "SelectLocation",
      component: () => import("../views/address/SelectLocation.vue")
    },
    {
      path: "/message",
      name: "MessageCenter",
      component: () => import("../views/message/MessageCenter.vue")
    },
    {
      path: "/payment",
      name: "Payment",
      component: () => import("../views/payment/Payment.vue")
    },
    {

      path: "/search",
      name: "search",

      component: () => import("../views/Search/search.vue")
    },
    {
      path:"/login",
      name:"Login",
      component: () => import("../views/login.vue")


    },
    {
      path:"/sort",
      name:"Sort",
      component: () => import("../views/Sort/sort.vue")
    }
  ]
});

// 添加全局导航守卫
router.beforeEach((to, from, next) => {
  console.log('Navigating to:', to.path);
  next();
});

export default router; // 导出路由实例供应用使用